package javaMetaModel;

import java.util.HashMap;
import java.util.Map;

import javaMetaModel.type.MetaType;

public abstract class Declaration implements IModifiableEntity,
		ICommentableEntity, IConfigurableEntity {

	protected String mName;

	protected MetaType mType;

	protected final Modifier mModifier = new Modifier();

	protected final Comments mComments = new Comments();

	protected final Map<String, String> mProperties = new HashMap<String, String>();

	public Declaration(MetaType aType, String aName) {
		this.mType = aType;
		this.mName = aName;
	}

	public String getName() {
		return mName;
	}

	public void setName(String mName) {
		this.mName = mName;
	}

	public MetaType getType() {
		return mType;
	}

	public void setType(MetaType mType) {
		this.mType = mType;
	}

	@Override
	public Modifier getModifier() {
		return mModifier;
	}

	@Override
	public boolean isAbstract() {
		return this.mModifier.isAbstract();
	}

	@Override
	public void setAbstract(boolean mIsAbstract) {
		this.mModifier.setAbstract(mIsAbstract);
	}

	@Override
	public boolean isFinal() {
		return this.mModifier.isFinal();
	}

	@Override
	public void setFinal(boolean mIsFinal) {
		this.mModifier.setFinal(mIsFinal);
	}

	@Override
	public boolean isStatic() {
		return this.mModifier.isStatic();
	}

	@Override
	public void setStatic(boolean mIsStatic) {
		this.mModifier.setStatic(mIsStatic);
	}

	@Override
	public Comments getComments() {
		return this.mComments;
	}

	@Override
	public void addComment(String aComment) {
		this.mComments.addComment(aComment);
	}

	@Override
	public void setComment(String aComment) {
		this.mComments.setComment(aComment);
	}

	@Override
	public boolean hasComment() {
		return this.mComments.hasComment();
	}

	@Override
	public String getProperty(String aKey) {
		return this.mProperties.get(aKey);
	}

	@Override
	public String getProperty(String aKey, String aDefaultValue) {
		String result = this.getProperty(aKey);
		if (result == null) {
			result = aDefaultValue;
		}
		return result;
	}

	@Override
	public void setProperty(String aKey, String aProperty) {
		this.mProperties.put(aKey, aProperty);
	}

	@Override
	public Map<String, String> getProperties() {
		return this.mProperties;
	}

}
